<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center courseIntroduction_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub courseIntroduction_fd0_0'>
					<view class='flex flex-wrap align-center courseIntroduction_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  courseIntroduction_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='courseIntroduction_fd0_0_c1_c0'
							style="font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;">{{name}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-end courseIntroduction_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<view class="loading_css" v-if="isShow">
				<u-loading size="36" color="#AD3823"></u-loading>
				<view>加载中</view>
			</view>
			<block v-else>

				<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout courseIntroduction_flex_1">
					<view class='flex flex-direction flex-wrap align-stretch courseIntroduction_fd1_0'>
						<view class='flex flex-wrap align-center'>
							<view class='flex flex-direction flex-wrap align-stretch'>
								<text class='courseIntroduction_fd1_0_c0_c0_c0'
									style="font-family: Alimama DongFangDaKai;">{{detailsInfo.title}}</text>
								<text class='courseIntroduction_fd1_0_c0_c0_c1'>{{detailsInfo.update_time}}</text>
							</view>
							<image class='courseIntroduction_fd1_0_c0_c1' mode="aspectFill" :src='STATIC_URL+"505.png"'>
							</image>
						</view>
						<view class='flex flex-wrap align-center' style="margin-top: 24rpx;">
							<!-- <text class='courseIntroduction_fd1_0_c1_c0'></text> -->
							<u-parse :html="detailsInfo.content"></u-parse>
						</view>
					</view>
					<view class='courseIntroduction_fd1_1' v-if="detailsInfo.data_type == 1">
						<!-- <image class='courseIntroduction_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"506.png"'></image> -->
						<u-swiper @click="imageClick" :list="detailsInfo.images" height="400"
							border-radius="16"></u-swiper>
					</view>
					<view class='courseIntroduction_fd1_1' v-if="detailsInfo.data_type == 2">
						<block v-if="!is_play">
							<image class='courseIntroduction_fd1_1_c0' mode="aspectFill" :src='detailsInfo.video_img'>
							</image>
							<image @tap.stop="playVideo" class="video_play" :src='STATIC_URL+"545.png"'
								mode="aspectFill"></image>
						</block>
						<view v-show="is_play">
							<video id="myVideo" style="border-radius: 0;" class='courseIntroduction_fd1_1_c0'
								object-fit="fill" :autoplay="false" :src="detailsInfo.video" @pause="videoPause"
								@ended="videoEnd" @error="videoError"></video>
						</view>
					</view>
				</view>

			</block>
		</view>
	</view>
</template>
<script>
	export default {
		components: {},


		data() {
			return {
				aid: "",
				name: "",
				detailsInfo: {
					images: [],
				},
				isShow: true,
				is_play: false,
				videoContext: null
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				aid,
				name
			} = options;
			if (aid !== undefined) this.aid = aid;
			if (name !== undefined) this.name = name;
			this.getDetails();
		},
		onUnload() {

		},
		onReady() {
			this.videoContext = uni.createVideoContext('myVideo', this);
		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// 详情  65533d74d699b
			getDetails() {
				this.$api.post(global.API_VERSION + '65533d74d699b', {
					course_id: this.aid
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						this.detailsInfo = res.data.data;
						if (res.data.data.data_type == 3) {
							let parm = encodeURIComponent(this.detailsInfo.video);
							uni.redirectTo({
								url: '/pages/shouye/courseIntroduction/playVideo?src=' + parm
							})
						} else {
							this.isShow = false;
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			imageClick(index) {
				let _this = this;
				uni.previewImage({
					current: index, //预览图片的下标
					urls: _this.detailsInfo.images //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
				})
			},
			playVideo() {
				this.is_play = true;
				this.videoContext.play();
			},
			videoPause() {
				this.is_play = false;
			},
			videoEnd() {
				this.is_play = false;
			},
			videoError() {
				this.$message.info('视频播放失败');
				this.is_play = false;
			},
		}
	};
</script>
<style lang="scss" scoped>
	.video_play {
		width: 72rpx;
		height: 72rpx;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: url(https://www.guochaoxiaoju.com/uploads/mini/504.png) no-repeat;
		background-size: 100% 100%;
	}

	.courseIntroduction_flex_0 {
		// background: url(https://www.guochaoxiaoju.com/uploads/mini/504.png) no-repeat;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.courseIntroduction_fd0_0_c1_c0 {
		font-size: 40rpx;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 88rpx;
	}

	.courseIntroduction_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: var(--benbenFontColor3);
	}

	.courseIntroduction_fd0_0_c0 {
		width: 120rpx;
	}

	.courseIntroduction_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.courseIntroduction_flex_1 {
		padding: 39rpx 30rpx 0rpx 30rpx;
	}

	.courseIntroduction_fd1_1_c0 {
		width: 690rpx;
		height: 400rpx;
		border-radius: 16rpx;
	}

	.courseIntroduction_fd1_1 {
		margin: 0rpx 0rpx 40rpx 0rpx;
		width: 690rpx;
		height: 400rpx;
		position: relative;
	}

	.courseIntroduction_fd1_0_c1_c0 {
		color: #333333;
		font-size: 32rpx;
		font-weight: 400;
		line-height: 48rpx;
		padding: 34rpx 0rpx 0rpx 0rpx;
	}

	.courseIntroduction_fd1_0_c0_c1 {
		width: 80rpx;
		height: 80rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.courseIntroduction_fd1_0_c0_c0_c1 {
		color: #999999;
		font-size: 24rpx;
		font-weight: 400;
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.courseIntroduction_fd1_0_c0_c0_c0 {
		color: #333333;
		font-size: 40rpx;
		font-weight: 400;
	}

	.courseIntroduction_fd1_0 {
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		width: 690rpx;
		padding: 32rpx 28rpx 32rpx 28rpx;
		margin: 0rpx 0rpx 24rpx 0rpx;
	}
</style>